package ${org}.${project}.common.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ${org}.${project}.common.dao.${modelName?cap_first}Dao;
import ${org}.${project}.common.model.${modelName?cap_first};

import ${org}.${project}.common.model.GridResponse;
import ${org}.${project}.common.model.ReturnModel;
import ${org}.${project}.common.enums.StatusEnum;
import ${org}.${project}.service.ICommonService;
/**
 * ${modelComment !}
 * @author CodeGen
 *
 */

@Transactional(rollbackFor=Exception.class)  
@Service
public class ${modelName?cap_first}ServiceImpl implements ${modelName?cap_first}Service {
	@Autowired
	private ${modelName?cap_first}Dao ${modelName?uncap_first}Dao;
	@Autowired
	private ICommonService commonService;
	@Override
	public void add(${modelName?cap_first} ${modelName?uncap_first}) throws Exception {
		${modelName?uncap_first}.setId(commonService.getNonaTime());
		${modelName?uncap_first}.setCreateTime(new Timestamp(new Date().getTime()));
		
		${modelName?uncap_first}Dao.insert(${modelName?uncap_first});
	}
	
	@Override
	public void delete(String[] ids) throws Exception{
		for (String id : ids) {
			${modelName?uncap_first}Dao.deleteById(id);
		}

	}
	
	@Override
	public void deleteById(String id) throws Exception{
		${modelName?uncap_first}Dao.deleteById(id);

	}

	@Override
	public void updateById(String id) throws Exception {
		${modelName?uncap_first}Dao.updateById(id);
	}
	
	@Override
	public GridResponse<${modelName?cap_first}> getPage(${modelName?cap_first} ${modelName?uncap_first}) throws Exception{
		return ${modelName?uncap_first}Dao.getPage(${modelName?uncap_first});
	}
	

	@Override
	public ${modelName?cap_first} findById(String id) throws Exception {
		return ${modelName?uncap_first}Dao.findById(id);
	}
		
}